package com.video.videos.controller;


import com.video.common.enumeration.AppHttpCodeEnum;
import com.video.common.result.PageResult;
import com.video.common.result.ResponseResult;
import com.video.videos.domain.dto.InsertCommentDto;
import com.video.videos.domain.dto.QueryCommentDto;
import com.video.videos.domain.dto.QueryPageDto;
import com.video.videos.service.ICommentService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author la
 * @since 2024-11-13
 */
@RestController
@RequestMapping("/comment")
@RequiredArgsConstructor
public class CommentController {

    private final ICommentService service;

    /*
     * 分页查询列表
     * */
    @GetMapping("/list")
    public ResponseResult list(QueryCommentDto dto) {
        PageResult result = service.queryCommentList(dto);
        return ResponseResult.okResult(result);
    }

    /*
     * 新增评论
     * */
    @PostMapping("/publish")
    public ResponseResult addComment(@RequestBody  InsertCommentDto dto) {
        service.publishComment(dto);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

}
